package com.gy.spark.core.others.topn

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

object TopN {
  def main(args: Array[String]) {
    val conf = new SparkConf().setAppName(this.getClass.getSimpleName).setMaster("local")
    val sc = new SparkContext(conf)

    val lines = sc.textFile("spark/input/scores.txt")

    val lineList = lines.map(x => (x.split("\t")(1), x))

    val sortRdd = lineList.sortByKey(false)


    val resultRDD = sortRdd.map(x => x._2)

    for (a <- resultRDD.take(5)) {
      println(a)
    }


  }
}